#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：AutoMagic 
@File    ：actions_handlers.py
@Author  ：赵加响
@Date    ：2023/1/3 10:36 
@Desc    ：
"""
from time import sleep

from selenium.webdriver.common.action_chains import ActionChains

from element_handlers.element_handlers import ElementHandlers


class ActionHandlers:

    def action_click(self, driver, element):
        """
        行为事件--以element对象作为参数的click
        :param driver:
        :param element:
        :return:
        """
        action = ActionChains(driver)
        sleep(0.5)
        action.click(element).perform()

    def action_click_xpath(self, driver, xpath_expression):
        """
        行为事件--以XPATH作为参数的click
        :param driver:
        :param xpath_expression:
        :return:
        """
        element = ElementHandlers().element_get(driver, xpath_expression)
        action = ActionChains(driver)
        sleep(0.5)
        action.click(element).perform()
